﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BLL
{
    public class BookTimeSlot
    {
        string[] timeSlots = new string[]{"09:00-10:00", "10:00-11:00","11:00-12:00", "12:00-13:00", "13:00-14:00", "14:00-15:00", "15:00-16:00",
                                            "16:00-17:00", "17:00-18:00", "18:00-19:00", "19:00-20:00", "20:00-21:00"};
        public string[] getAllTimeSlots()
        {
            return timeSlots;
        }

        public List<string> getBookedTimeSlots(DAL.Booking book)
        {
            DAL.Booking booking = new DAL.Booking();
            return booking.getBookedTimeSlots(book);
        }

        public List<string> getAvailableTimeSlots(DAL.Booking book)
        {
            string[] bookedTimeSlots = getBookedTimeSlots(book).ToArray<string>();
            List<string> availableTimeSlots = new List<string>();
            int flag = 0;
            for (int i = 0; i < bookedTimeSlots.Length; i++)
            {
                for (int j = flag; j < timeSlots.Length; j++)
                {
                    flag = j + 1;
                    if (timeSlots[j] != bookedTimeSlots[i])
                    {
                        availableTimeSlots.Add(timeSlots[j]);
                        
                    }
                    else
                        break;
                }
            }
            if (flag < timeSlots.Length)
            {
                for (int i = flag; i < timeSlots.Length; i++)
                {
                    availableTimeSlots.Add(timeSlots[i]);
                }
            }
            return availableTimeSlots;
        }
    }
}
